package com.duoketech.service.orderitem;
import com.duoketech.service.AbstractService;
import com.duoketech.model.orderitem.OrderItem;
import com.duoketech.exception.ValidateException;
import com.duoketech.utils.search.QueryConstructor;
import com.duoketech.utils.validator.Validator;
import com.duoketech.utils.validator.rules.string.StringLengthBetween;
import com.duoketech.utils.validator.rules.string.StringMustBeRequired;
import com.jfinal.kit.Kv;
import com.jfinal.plugin.activerecord.Model;
import java.util.Map;
public class OrderItemService extends AbstractService{
    public static OrderItemService ME = new OrderItemService();

    @Override
    public void validatorUpdate(Model<?> model, Kv kv) throws ValidateException {
        validatorAdd(model,kv);
    }

    @Override
    public void validatorAdd(Model<?> model, Kv kv) throws ValidateException {

        Validator validator = new Validator();
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.ID),"项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.ID),"项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.PRODUCT_ID),"产品 id项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.PRODUCT_ID),"产品 id项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.MEMBER_ID),"会员 id项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.MEMBER_ID),"会员 id项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.STATUS),"状态项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.STATUS),"状态项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.CREATE_TIME),"创建时间项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.CREATE_TIME),"创建时间项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.MODIFY_TIME),"修改时间项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.MODIFY_TIME),"修改时间项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.NUM),"购买数量项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.NUM),"购买数量项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.PRICE),"单价项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.PRICE),"单价项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.TOTAL_PRICE),"总价项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.TOTAL_PRICE),"总价项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.TOTAL_WEIGHT),"重量项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.TOTAL_WEIGHT),"重量项字符必须为1-50个字符",1,50));
        validator.addRule(new StringMustBeRequired(model.getStr(OrderItem.ORDER_ID),"order_id项为必填信息"));
        validator.addRule(new StringLengthBetween(model.getStr(OrderItem.ORDER_ID),"order_id项字符必须为1-50个字符",1,50));
        validator.excute();

    }

    @Override
    public void beforAdd(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterAdd(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforUpdate(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterUpdate(Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforQuery(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterQuery(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void beforDelete(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public void afterDelete(int id, Model<?> model, Kv kv) throws ValidateException {

    }

    @Override
    public String tableName() {
        return OrderItem.dao.tableName();
    }

    @Override
    public void builderSQLExpected(Model<?> model, QueryConstructor queryConstruct, Kv kv) {

    }
}